// pages/reportInfo/reportInfo.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    datalist:[
      ['癌胚抗原', '1480', '1', '0.00-5.00','ng/ml','name1'],
      ['癌胚抗原', '1480', '1', '0.00-5.00', 'ng/ml','name2'],
      ['神经元特异性', '1480', '', '0.00-5.00', 'ng/ml','name3'],
      ['癌胚抗原', '1480', '', '0.00-5.00', 'ng/ml','name4'],
      ['神经元特异性', '1480', '', '0.00-5.00', 'ng/ml','name5'],
    ],
    barCode:'',
    reportArr:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var userInfo = wx.getStorageSync('trUserInfo');
    wx.setNavigationBarTitle({
      title: options.title
    })
    wx.request({
      url: getApp().globalData.host_url + '/medicalExReport/ajax_listMedicalExReport?barCode=' + options.barCode + "&userId=" + userInfo.userId,
      method: 'GET',
      data: {},
      success: function (res) {
        var listMedicalExReport = res.data.listMedicalExReport;
        if (listMedicalExReport == null) {
          var textToast = "信息获取失败！";
          wx.showToast({
            title: textToast,
            icon: '',
            duration: 2000
          })
        } else {
          var reportArr = [];
          //初始化被选中值
          for (var i = 0; i < listMedicalExReport.length; i++) {
            if (listMedicalExReport[i].jgts != '1'){
              reportArr.push(listMedicalExReport[i].medicalExReportId);
            }           
          }
          that.setData({
            datalist: listMedicalExReport,
            reportArr: reportArr
          })

          
        }
      }
    })
   



  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
 /**
   * 点击
   */
  // 获取多选框list中选中的值和对应的id
  checkboxChange: function (e) {
    var that = this;
    var reportArr = [];
    for (var i = 0; i < e.detail.value.length; i++) {
      reportArr.push(e.detail.value[i]);
    }
    that.setData({
      reportArr: reportArr
    })
  },
  addFlup: function (e) {
    var that = this;
    var reportArr = that.data.reportArr;
    var userInfo = wx.getStorageSync('trUserInfo');
    wx.request({
      url: getApp().globalData.host_url + '/flup/ajax_addWxFlup?reportArr=' + reportArr + "&userId=" + userInfo.userId,
      method: 'GET',
      data: {},
      success: function (res) {
        var info = res.data.info;
        var textToast = res.data.infoMsg;
        wx.showToast({
          title: textToast,
          icon: '',
          duration: 2000
        })

      }
    })
  }
})